package zhh.tangbao.wechat.vo.cart;

import lombok.Data;
import zhh.tangbao.commodity.vo.stock.CartStockVo;
import zhh.tangbao.wechat.pojo.CartItem;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * <p>
 * 描述
 * </p>
 *
 * @author 粥灰灰
 * <p>2023/5/2</p>
 */

@Data
public class CartItemVo extends CartItem {

    private String machineName;

    private String commodityImg;

    private String commodityName;

    private Double price;


    private Integer toBeSold;

    private Integer count = 0;

    public CartItemVo(CartItem item, CartStockVo vo) {
        super(item.getCommodityEntityId(), item.getMachineId(), item.getStockId());
        this.machineName = vo.getMachineName();
        this.commodityImg = vo.getCommodityImg();
        this.commodityName = vo.getCommodityName();
        this.toBeSold = vo.getToBeSold();
        this.price = new BigDecimal(vo.getCommodityPrice() * vo.getCommodityPriceIncrease()).setScale(2, RoundingMode.HALF_UP).doubleValue();

    }
}
